documentation
[lhc/web/wiklou.git] / includes / ChangesList.php
index 97da138..4703e78 100644 (file)
@@ -39,7 +39,7 @@ class ChangesList {
                $this->skin =& $skin;
                $this->preCacheMessages();
        }
-       
+
        function newFromUser( &$user ) {
                $sk =& $user->getSkin();
                if( $user->getOption('usenewrc') ) {
@@ -175,14 +175,14 @@ class ChangesList {
 
        function insertTimestamp(&$s, &$rc) {
                global $wgLang;
-        # Timestamp
-        $s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
+               # Timestamp
+               $s .= '; ' . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
        }
 
        /** Insert links to user page, user talk page and eventually a blocking link */
        function insertUserRelatedLinks(&$s, &$rc) {
-               $s .= $this->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
-               $s .= $this->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+               $s .= $this->skin->userLink( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
+               $s .= $this->skin->userToolLinks( $rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text'] );
        }
 
        /** insert a formatted comment */
@@ -192,90 +192,17 @@ class ChangesList {
                        $s .= $this->skin->commentBlock( $rc->mAttribs['rc_comment'], $rc->getTitle() );
                }
        }
-       
+
        /**
-        * Check whether to enable RC-Patrol features
+        * Check whether to enable recent changes patrol features
         * @return bool
         */
        function usePatrol() {
-               global $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgUser;
-               return $wgUseRCPatrol && $wgUser->isLoggedIn() &&
-                 ( !$wgOnlySysopsCanPatrol || $wgUser->isAllowed( 'patrol' ) );
-       }
-       
-       /**
-        * Make user link (or user contributions for unregistered users)
-        * @param int $userId
-        * @param string $userText
-        * @return string HTML fragment
-        * @access private
-        */
-       function userLink( $userId, $userText ) {
-               $encName = htmlspecialchars( $userText );
-               if( $userId == 0 ) {
-                       $contribsPage = Title::makeTitle( NS_SPECIAL, 'Contributions' );
-                       return $this->skin->makeKnownLinkObj( $contribsPage,
-                               $encName, 'target=' . urlencode( $userText ) );
-               } else {
-                       $userPage = Title::makeTitle( NS_USER, $userText );
-                       return $this->skin->makeLinkObj( $userPage, $encName );
-               }
-       }
-       
-       /**
-        * @param int $userId
-        * @param string $userText
-        * @return string HTML fragment with talk and/or block links
-        * @access private
-        */
-       function userToolLinks( $userId, $userText ) {
-               global $wgUser, $wgDisableAnonTalk, $wgSysopUserBans;
-               $talkable = !( $wgDisableAnonTalk && 0 == $userId );
-               $blockable = ( $wgSysopUserBans || 0 == $userId );
-               
-               $items = array();
-               if( $talkable ) {
-                       $items[] = $this->userTalkLink( $userId, $userText );
-               }
-               if( $blockable && $wgUser->isAllowed( 'block' ) ) {
-                       $items[] = $this->blockLink( $userId, $userText );
-               }
-               
-               if( $items ) {
-                       return ' (' . implode( ' | ', $items ) . ')';
-               } else {
-                       return '';
-               }
-       }
-       
-       /**
-        * @param int $userId
-        * @param string $userText
-        * @return string HTML fragment with user talk link
-        * @access private
-        */
-       function userTalkLink( $userId, $userText ) {
-               global $wgContLang;
-               $talkname = $wgContLang->getNsText( NS_TALK ); # use the shorter name
-               
-               $userTalkPage = Title::makeTitle( NS_USER_TALK, $userText );
-               $userTalkLink = $this->skin->makeLinkObj( $userTalkPage, $talkname );
-               return $userTalkLink;
-       }
-       
-       /**
-        * @param int $userId
-        * @param string $userText
-        * @return string HTML fragment with block link
-        * @access private
-        */
-       function blockLink( $userId, $userText ) {
-               $blockPage = Title::makeTitle( NS_SPECIAL, 'Blockip' );
-               $blockLink = $this->skin->makeKnownLinkObj( $blockPage,
-                       $this->message['blocklink'], 'ip=' . urlencode( $userText ) );
-               return $blockLink;
+               global $wgUseRCPatrol, $wgUser;
+               return( $wgUseRCPatrol && $wgUser->isAllowed( 'patrol' ) );
        }
 
+
 }
 
 
@@ -287,7 +214,7 @@ class OldChangesList extends ChangesList {
         * Format a line using the old system (aka without any javascript).
         */
        function recentChangesLine( &$rc, $watched = false ) {
-               global $wgLang, $wgContLang, $wgUser, $wgSysopUserBans;
+               global $wgContLang;
 
                $fname = 'ChangesList::recentChangesLineOld';
                wfProfileIn( $fname );
@@ -351,7 +278,7 @@ class EnhancedChangesList extends ChangesList {
         * Format a line for enhanced recentchange (aka with javascript and block of lines).
         */
        function recentChangesLine( &$baseRC, $watched = false ) {
-               global $wgLang, $wgContLang, $wgUser, $wgSysopUserBans;
+               global $wgLang, $wgContLang;
 
                # Create a specialised object
                $rc = RCCacheEntry::newFromParent( $baseRC );
@@ -429,13 +356,13 @@ class EnhancedChangesList extends ChangesList {
                          $curIdEq.'&diff='.$rc_this_oldid.'&oldid='.$rc_last_oldid . $rcIdQuery );
                }
 
-               $rc->userlink = $this->userLink( $rc_user, $rc_user_text );
-               
+               $rc->userlink = $this->skin->userLink( $rc_user, $rc_user_text );
+
                $rc->lastlink = $lastLink;
                $rc->curlink  = $curLink;
                $rc->difflink = $diffLink;
 
-               $rc->usertalklink = $this->userToolLinks( $rc_user, $rc_user_text );
+               $rc->usertalklink = $this->skin->userToolLinks( $rc_user, $rc_user_text );
 
                # Put accumulated information into the cache, for later display
                # Page moves go on their own line
@@ -452,7 +379,7 @@ class EnhancedChangesList extends ChangesList {
                }
                return $ret;
        }
-       
+
        /**
         * Enhanced RC group
         */
@@ -534,6 +461,7 @@ class EnhancedChangesList extends ChangesList {
                $r .= $users;
 
                if($block[0]->numberofWatchingusers > 0) {
+                       global $wgContLang;
                        $r .= wfMsg('number_of_watching_users_RCview',  $wgContLang->formatNum($block[0]->numberofWatchingusers));
                }
                $r .= "<br />\n";
@@ -575,7 +503,7 @@ class EnhancedChangesList extends ChangesList {
                $this->rcCacheIndex++;
                return $r;
        }
-       
+
        function maybeWatchedLink( $link, $watched=false ) {
                if( $watched ) {
                        // FIXME: css style might be more appropriate
@@ -584,7 +512,7 @@ class EnhancedChangesList extends ChangesList {
                        return $link;
                }
        }
-       
+
        /**
         * Generate HTML for an arrow or placeholder graphic
         * @param string $dir one of '', 'd', 'l', 'r'
@@ -598,7 +526,7 @@ class EnhancedChangesList extends ChangesList {
                $encAlt = htmlspecialchars( $alt );
                return "<img src=\"$encUrl\" width=\"12\" height=\"12\" alt=\"$encAlt\" />";
        }
-       
+
        /**
         * Generate HTML for a right- or left-facing arrow,
         * depending on language direction.
@@ -610,7 +538,7 @@ class EnhancedChangesList extends ChangesList {
                $dir = $wgContLang->isRTL() ? 'l' : 'r';
                return $this->arrow( $dir, '+' );
        }
-       
+
        /**
         * Generate HTML for a down-facing arrow
         * depending on language direction.
@@ -620,7 +548,7 @@ class EnhancedChangesList extends ChangesList {
        function downArrow() {
                return $this->arrow( 'd', '-' );
        }
-       
+
        /**
         * Generate HTML for a spacer image
         * @return string HTML <img> tag